package com.example.selflearning.mapper;

import com.example.selflearning.entity.UserEntity;
import com.example.selflearning.entity.UserSexEnum;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;
/**
 * Created by yangjingzhi on 2019/5/16.
 */
/*
@CacheNamespace(blocking = true)
*/
public interface UserMapper {
   /* @Select("SELECT * FROM users")
    @Results({
            @Result(property = "userSex",  column = "user_sex", javaType = UserSexEnum.class),
            @Result(property = "userName", column = "nick_name")
    })


     @Select("SELECT * FROM users WHERE id = #{id}")
    @Results({
            @Result(property = "userSex",  column = "user_sex", javaType = UserSexEnum.class),
            @Result(property = "userName", column = "nick_name")
    })
    UserEntity getOne(Long id);

    @Insert("INSERT INTO users(nick_name,passWord,user_sex) VALUES(#{userName}, #{passWord}, #{userSex})")
    void insert(UserEntity user);

    @Update("UPDATE users SET userName=#{userName},nick_name=#{nickName} WHERE id =#{id}")
    void update(UserEntity user);

    @Delete("DELETE FROM users WHERE id =#{id}")
    void delete(Long id);*/

    List<UserEntity> getAll();
    List<UserEntity>  findAllEntity();
    UserEntity    findOne(int id);
    void addOne(UserEntity user);
}
